<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="../org/jquery.min.js"></script>
    <script src="../org/angular.min.js"></script>
</head>
<body>

<div ng-app="hd">
    <div ng-controller="ctrl">
    {{name1}}<hr>
    {{name2}}<hr>
        {{id}}

    </div>

</div>


<script>

    var m = angular.module('hd', []);
    m.controller('ctrl', ['$scope', '$timeout', '$interval', function ($scope, $timeout, $interval) {
        $scope.name1 = '后盾人1';
        $scope.name2 = '后盾人2';

        $scope.id = 1;

        //juery的定时器实现
        setTimeout(function () {
            $scope.name2 = 'houduenren2.com';
            $scope.$apply();
        }, 2000);

        var timeId = $timeout(function () {  //超时服务的使用
        }, 3000);
        $scope.name1 = 'houdunren1.com';
        $timeout.cancel(timeId);   //撤销定超时服务

        var interId = $interval(function () { //定时器服务
            $scope.id++;
            if($scope.id >= 10){
                $interval.cancel(interId); //撤销定时器服务
            }

        }, 1000);



    }]);

</script>

</body>
</html>

